<?php

class Core_Backend_Component_Customer_View_Showroom_Create extends Core_Backend_Share_View_Form {

    protected function buildToolbar($toolbar) {
        $group = $toolbar->createGroup('back');
        $group->addLink($this->getHistoryUrl('index'), $this->__('share.button.back'));
        $group = $toolbar->createGroup('save');
        $group->addButton($this->__('share.button.save'))
                ->bindEvent('click', "Kdf.Ui.getForm('" . $this->getForm()->getId() . "').submit('" . $this->getUrl(NULL, 'save') . "')");        
        $group->addButton($this->__('share.button.submit'))
                ->bindEvent('click', "Kdf.Ui.getForm('" . $this->getForm()->getId() . "').submit('" . $this->getUrl(NULL, 'submit') . "')");
        parent::buildToolBar($toolbar);
    }

    protected function buildForm($form) {
        $entity = $this->getModel(NULL);
        $form->setAction($this->getUrl())
                ->setId('showroom_form')
                ->addHiddenField('id', 'showroom[id]')
                ->addHiddenField('poi_id', 'showroom[poi_id]', $this->getPoi()->getId());
        $form->addTextboxField($this->__('share.label.name'), 'name', 'showroom[name]', TRUE)
                ->addValidateRule('required');
        $form->addTextboxField($this->__('customer.label.sd_url'), 'sd_url', 'showroom[sd_url]', TRUE)
                ->addValidateRule('required');
        $form->addTextboxField($this->__('customer.label.hd_url'), 'hd_url', 'showroom[hd_url]');
		$form->addTextareaField($this->__('share.label.introduction'), 'introduction', 'content[introduction]');        
        $form->addFileField($this->__('customer.label.preview_image'), 'preview_image', 'showroom[preview_image]');
        
        if (!is_null($entity)) {
            $form->bindData($entity->getAllData());
			$form->addHiddenField('ids', 'ids[]', $this->getModel()->getId());
			$form->getInput('preview_image')
				 ->setBaseUrl($this->getRouter()->getBaseUrl().'pub/customer/showroom/'.$entity->getId().'/');            
        }
        parent::buildForm($form);
    }

}